$(function () {

    getUserInfo();
    // 退出
    $("#btnOut").on("click", function () {
        localStorage.removeItem("token")
        location.href = '/login.html'
    })

})

function getUserInfo() {
    $.ajax({
        url: '/admin/user/info',
        type: 'get',

        dataType: 'json',
        headers: {
            Authorization: localStorage.getItem("token") || ''
        },
        success: (res) => {
            // console.log(res);
            // console.log(1);
            if (res.code == 200) {
                $(".text-avatar").hide()
                $(".layui-nav-img").attr('src', res.data.userPic)
                $("#welcome").html(res.data.nickname)
            }
        }
    })
}